package com.train.pattern.strategy.v2.pay.discount;


import com.train.pattern.strategy.v2.pay.MemberTypeEnum;

/**
 * @author hugx
 * @create 2021-01-15 14:24
 */
public class CommonDiscountStrategy implements DiscountStrategy {
    private int discount=10;
    @Override
    public double discountCompute(double totalMoney) {
        double  result= (this.discount * totalMoney ) / 10;
        double discountMoney=totalMoney - result;
        discountMoney=Math.round(discountMoney * 100) / 100.00;
        result=Math.round(result * 100) / 100.00;

        StringBuilder sb=new StringBuilder(MemberTypeEnum.COMMON.getDesc());
        sb.append("享受 ").append(this.discount ).append(" 折优惠， 本次享受到的优惠金额为： ").append(discountMoney);
        System.out.println(sb.toString());
        return result;
    }
}
